package com.taiyi.renaissancemall.ui.mine.order.sale

import android.content.Intent
import android.os.Bundle
import com.taiyi.renaissancemall.R
import com.taiyi.renaissancemall.Utils.load
import com.taiyi.renaissancemall.base.BaseActivity
import com.taiyi.renaissancemall.bean.OrderListBean
import com.taiyi.renaissancemall.ui.mine.order.sale.refund.ApplyRefundActivity
import kotlinx.android.synthetic.main.activity_apply_sale.*
import kotlinx.android.synthetic.main.base_top_white_background_layout.*

class ApplySaleActivity : BaseActivity<ApplySaleView, ApplySalePresent>() {


    override fun getLayoutId(): Int = R.layout.activity_apply_sale

    override fun initPresenter(): ApplySalePresent = ApplySalePresent()

    override fun initViews(savedInstanceState: Bundle?) {
        titleTv.text = getString(R.string.applySale)
        var product = intent.getSerializableExtra("product") as OrderListBean.OrderlistBean
        var ifHui = intent.getStringExtra("ifHui")
        productIv.load(product?.smallimgurl)
        productNameTv.text = product?.name
        specTv.text = product?.typename
        quantityTv.text = "x" + product?.number
        if ("1" == ifHui)
            priceTv.text = "￥" + product?.hyprice
        else
            priceTv.text = "￥" + product?.price
        refundTv.setOnClickListener {
            //退款无需退货
            var intent = Intent(this, ApplyRefundActivity::class.java)
            intent.putExtra("typeCode", "1")
            intent.putExtra("oId", product.ordercommodityid)
            startActivity(intent)
            finish()
        }
        returnTv.setOnClickListener {
            //退款退货
            var intent = Intent(this, ApplyRefundActivity::class.java)
            intent.putExtra("typeCode", "2")
            intent.putExtra("oId", product.ordercommodityid)
            startActivity(intent)
            finish()
        }
        exchangeTv.setOnClickListener {
            //换货
            var intent = Intent(this, ApplyRefundActivity::class.java)
            intent.putExtra("typeCode", "3")
            intent.putExtra("oId", product.ordercommodityid)
            startActivity(intent)
            finish()
            //刷新
        }
    }

    override fun initImmersionBar() {
        super.initImmersionBar()
        mImmersionBar.titleBar(top).init()
    }

    override fun initData() {

    }

    override fun initEvent() {
        backIv.setOnClickListener { finish() }
    }
}
